<?php
include 'include/functions.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//Dtd html 4.01 Transitional//EN"
"http://www.w3.org/tr/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/MAIN.dwt.php" codeOutsideHTMLIsLocked="false" -->
  <head>
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>JoshHughes.com NFL Football Pool</title>
    <!-- InstanceEndEditable -->
	<link rel="stylesheet" href="css/football.css" type="text/css">
    <script src="scripts/prototype.js" type="text/javascript"></script>
	<script src="scripts/scriptaculous.js" type="text/javascript"></script>
	<script type="text/javascript">
	// Dynamic Iframe loader
	function loadIframe(theFrame, theURL) {
		document.getElementById(theFrame).src=theURL;
	}
	
	// resizes Iframe according to content
	function resizeMe(obj){ 
	docHeight = mainContent.document.body.scrollHeight
	 obj.style.height = docHeight + 'px'
	 } 
	</script>
    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
  </head>
<body>
<div id="pagewidth" >
	<div id="header" >
	
		<?PHP include_once("layout/header.html"); ?>
		
	</div>
			<div id="wrapper" class="clearfix" > 
			<div id="maincol" >

			<!-- InstanceBeginEditable name="Contents" -->

				<?
				//Connect To Database
				dbConnect();
				
				$Conference = array("AFC", "NFC");
				$Division = array("East", "North", "South", "West");
				
				foreach ($Conference as $confkey)
					{
					?>	
					<table width="700" cellpadding="5" cellspacing="0">

						<tr>
							<td align="center" class="
						<?
							if ($confkey == "AFC") {
								echo "redbg";
							} else {
								echo "bluebg";
							}
						?>" height="1">
							<table width="100%" cellspacing="0" cellpadding="2" border="0" align="center">
						<?
						foreach ($Division as $divkey)
						{
							echo "<tr><TH width=\"100%\" colspan=\"11\" align=\"Left\"><span class=\"whitelink\">".$confkey." ".$divkey." Division</span></TH></tr>";
							?>
							<tr bgcolor="#FFFFFF">
								<TH width="45">&nbsp;</TH>
								<TH width="200" align="left">Team</TH>
								<TH width="90" align="left">W-L-T</TH>
								<TH width="40" align="left">PF</TH>
								<TH width="40" align="left">PA</TH>
								<TH width="50" align="left">Home</TH>
								<TH width="50" align="left">Road</TH>
								<TH width="50" align="left">AFC</TH>
								<TH width="50" align="left">NFC</TH>
								<TH width="50" align="left">DIV</TH>
								<TH width="40" align="left">Streak</TH>
							</tr>    
							<?
							//Write SQL Query to extract specified data
							$SQL = "SELECT * FROM NFLTeams WHERE ((Conference = '".$confkey."') AND (Division = '".$divkey."')) ORDER BY Wins DESC, Loses ASC";
							//Open Record Set using SQL Query
							$result = mysql_query($SQL) or die("Cannot query the database.<br>" . mysql_error());
							$row = 0;
							do{
								if (($myrow["TeamName"] != Null) || ($myrow["TeamName"] != "")) {
									$row++;
								echo "	<tr  bgcolor=\"".getrowColor($row)."\">
											<td align=\"left\"><img src=\"../images/small/".$myrow["TeamName"].".gif\"></td>
											<td align=\"left\">
											<B><a href=\"".$myrow["URL"]."\" class=\"permLink\" target=\"blank\" title=\"".$myrow["City"]." ".$myrow["TeamName"]." @ ".$myrow["URL"]."\">".$myrow["City"]." ".$myrow["TeamName"]."</a></B>
											</td>
											<td align=\"left\">".$myrow["Wins"]." - ".$myrow["Loses"]." - ".$myrow["Ties"]."</td>
											<td align=\"left\">".$myrow["PointsFor"]."</td>
											<td align=\"left\">".$myrow["PointsAgainst"]."</td>
											<td align=\"left\">".$myrow["HomeWins"]." - ".$myrow["HomeLosses"]."</td>
											<td align=\"left\">".$myrow["RoadWins"]." - ".$myrow["RoadLosses"]."</td>
											<td align=\"left\">".$myrow["AFCWins"]." - ".$myrow["AFCLosses"]."</td>
											<td align=\"left\">".$myrow["NFCWins"]." - ".$myrow["NFCLosses"]."</td>
											<td align=\"left\">".$myrow["DivWins"]." - ".$myrow["DivLosses"]."</td>
											<td align=\"left\"> ".$myrow["Streak"]."</td>
										</tr>";
								}
							}while($myrow = mysql_fetch_array($result));
						}//end 
					?>
						</table></td></tr></table><BR>
					<?
				} //end FOR EACH ($Conference) LOOP ?>

			<!-- InstanceEndEditable -->
			
			</div>
			<div id="leftcol" >
			
				<?PHP include_once("layout/left_column.php"); ?>
		
			</div>
			
		</div>
		
		<div id="footer" >
		
			<?PHP include_once("layout/footer.html"); ?>
			
		</div>
</div>
</body>
<!-- InstanceEnd --></html>